package com.example.demo.design.strategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * @author lyc
 * @date 2019/7/10.
 * @desc 持有所有的策略 上下文 对象
 */
@Component
public class ActivityContext {

    @Autowired
    ApplicationContext applicationContext;

    public  ActivityStrategy getStrategy(int type){
        // 校验 类型 活动是否存在
        return (ActivityStrategy) applicationContext.getBean(type+"");
    }
}